package com.pioneer.web.book.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pioneer.common.core.domain.BaseEntity;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 *
 * @TableName book
 */
@EqualsAndHashCode(callSuper = true)
@TableName(value ="book")
@Data
public class Book extends BaseEntity {
    /**
     * 图书ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 图书标题
     */
    @TableField(condition = SqlCondition.LIKE)
    @NotBlank(message = "图书标题不能为空")
    private String title;

    /**
     * 作者
     */
    @NotBlank(message = "作者不能为空")
    @TableField(condition = SqlCondition.LIKE)
    private String author;

    /**
     * 分类ID
     */
    private Long categoryId;

    /**
     * 出版社
     */
    @TableField(condition = SqlCondition.LIKE)
    private String publisher;

    /**
     * 出版日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate publishDate;

    /**
     * 当前库存
     */
    @DecimalMin(value = "0", message = "库存不能为负数")
    private BigDecimal stock;

    /**
     * 总藏书数量
     */
    @DecimalMin(value = "0", message = "库存不能为负数")
    private BigDecimal total;
}
